<template>
  <div class="app-container">
    <hd-table-page
      ref="hdTable"
      :columns="columns"
      :defaultData="defaultData"
      modulePath="attendance/record/statistic"
      style="height: calc(100% - 120px)"
      readOnly>
      <template #query-shiftDate="{ data, field }">
        <el-date-picker v-model="data[field.prop]" type="month" placeholder="选择月份" value-format="yyyy-MM"></el-date-picker>
      </template>
      <template #query-deptId="{ data, field }">
        <dept-select v-model="data[field.prop]" />
      </template>
      <template #actionButton="{ tableData, tableDataChild }">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="exportXls(tableData)" v-hasPermi="['attendance:record:export']">
          导出
        </el-button>
      </template>
    </hd-table-page>
  </div>
</template>

<script>
//考勤统计
import BaseService from '@/api/base/base'
const baseService = new BaseService('attendance/record/statistic')
export default {
  name: 'StatisticsAttendance',
  data() {
    return {
      // 导出遮罩层
      columns: [
        { type: 'index', label: '#', align: 'center' },
        { prop: 'personName', label: '姓名' },
        { prop: 'deptId', label: '部门', minWidth: '150px', isColumn: false },
        { prop: 'deptName', label: '部门', minWidth: '150px', isField: false, isSearch: false },
        { prop: 'groupName', label: '考勤组', isSearch: false },
        { prop: 'shiftDate', label: '月份', isColumn: false },
        { prop: 'statisticWork', label: '出勤天数', isSearch: false },
        { prop: 'statisticRest', label: '休息天数', isSearch: false },
        { prop: 'workHours', label: '工作时长(分钟)', isSearch: false },
        { prop: 'lateCount', label: '迟到次数', isSearch: false },
        { prop: 'lateHours', label: '迟到时长(分钟)', isSearch: false },
        { prop: 'earlyCount', label: '早退次数', isSearch: false },
        { prop: 'earlyHours', label: '早退时长(分钟)', isSearch: false },
        { prop: 'beginLackClock', label: '上班缺卡次数', isSearch: false },
        { prop: 'endLackClock', label: '下班缺卡次数', isSearch: false },
        { prop: 'holidayDuration', label: '请假天数', isSearch: false },
        { prop: 'holidayExchange', label: '调休天数', isSearch: false },
      ],
      defaultData: {
        form: {},
        queryParams: {
          shiftDate: this.$moment().format('YYYY-MM'),
        },
      },
    }
  },
  created() {},
  methods: {
    exportXls(tableData) {
      this.$confirm('是否确认导出?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          return baseService.export(tableData.queryParams)
        })
        .then((response) => {
          this.download(response.msg)
        })
    },
  },
}
</script>

<style lang="scss" scoped></style>
